plantsvszombiesfandomcom-20200213-history
User file format
The user file in Plants vs. Zombies contains data about your progress in the game, money, unlocked modes, trophies, achievements, purchased items, plants in your Zen Garden, and your Zombatars. By directly modifying the user file you can change any of these things, and do certain things that are either very difficult (like earning $999,990) or not possible in the game (like having a Cob Cannon in your Zen Garden). You can also do things that are very easy if you want. User file editor The easiest way to modify the user file if you have the PC version of Plants vs. Zombies is using the Plants vs. Zombies user file editor. See screenshot at right and sample video below that walks through some of the features. To use the user file editor, simply download the ZIP archive, extract it, and execute the application. It will locate the file and provide options to edit it. It automatically creates backups of your user file, so it is safe to use. Report any issues to dc@moonflare.com or User talk:Dcoetzee. Full source code is available from github under the Creative Commons Zero Waiver. The remainder of this article describes the format of the user file. This information can be used to directly modify the user file using a hex editor, such as Fhred, or to create new software tools to manipulate it. File location and version This information is based on the following version of Plants vs. Zombies (from readme.html in the installation directory): Version 1.2.0.1073 Release Date: May 5, 2009 Build Date: August 20, 2012 Your user file is called user1.dat. If you have multiple users, there might be user2.dat, etc. - they are in the order listed in users.dat. If your file starts with 0x0C (file version 12) it should be compatible with the below information. Otherwise there will be differences, but overall it should be similar. The game loads and saves user1.dat at startup/exit and when switching users, and also saves it at various other points. You must exit the game or select a different user to edit the file. You can only edit it after starting the first level. WARNING: Create a backup copy of your original user1.dat file before modifying it, or you may end up with a corrupt file that crashes the game and no way to recover! Example Say that you wanted to increase your money to $100000. The field for money (see below) is at offset 0x008, and is coded as the number 10000 (money divided by 10). The number 10000 in hexadecimal is 2710. The field is four bytes long, and the bytes (pairs of hexadecimal digits) are provided in reverse order (little endian), so this will be encoded as "10 27 00 00". So load user1.dat in your hex editor, go to offset 0x008 in the file, and change the next four bytes to "10 27 00 00". Types and formatting In the below, decimal integer values will be written normally (e.g. 25) and hexadecimal values preceded by "0x" as in "0x1C". All values are little-endian. Fields labelled "UNIX timestamp" are given in terms of the number of seconds since Jan 1, 1970 12:00:00am in UTC and can be converted using this online converter . File format Followed by 88 (0x58) bytes for each plant in the Zen Garden, with the following structure: The Zen Garden plants are followed by the following fields. In the table below offsets start after the last plant. To find the base, take the number at offset 0x330 (number of plants), multiply it by 88 (0x58), and add 0x334. Followed by 72 (0x48) bytes for each Zombatar, with the following structure: The Zombatars are followed by the following fields. In the table below offsets start after the last Zombatar. To find the base, take the number at offset 0x330 (number of plants), multiply it by 88 (0x58), take the number at offset 0x2D (number of Zombatars), multiply it by 72 (0x48), and add both to 0x365. Notes *The game sets achievements to 0x0101 when obtained, but any nonzero value will work. Some achievements are set to 1 automatically at startup if their conditions are already met and cannot be turned off (e.g. Towering Wisdom achievement if height of the Tree of Wisdom is at least 100 ft, Home Lawn Security if Adventure Mode is completed at least once). *There is no field for the Gold Sunflower Trophy. You get it automatically if you enable all other trophies. Category:Cheats